//
//  CommonMacro.h
//  JAC_DMS_SALES
//
//  Created by 贺佳 on 2018/5/8.
//  Copyright © 2018年 zhoufang. All rights reserved.
//

#ifndef CommonMacro_h
#define CommonMacro_h

#ifdef DEBUG
#define HJLog(...)    NSLog(__VA_ARGS__)
#else
#define HJLog(...)
#endif
//BOOL bAlbumListViewStatus=NO; //是否是相册
//适配x
#define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size): NO)

#define NAVIHEIGHT kDevice_Is_iPhoneX?88:64

#pragma mark -- 单例
//初始化方法
#define InitFrameM \
-(instancetype)initWithFrame:(CGRect)frame \
{ \
if (self==[super initWithFrame:frame]) { \
[self setUI]; \
} \
return self; \
}
//table .h文件
#define UITablecellH  +(instancetype)cellWithTable:(UITableView*)tableView;
// .m文件
#define UITablecellM(cellID) \
+(instancetype)cellWithTable:(UITableView *)tableView \
{ \
static NSString*ID=cellID; \
id cell=[tableView dequeueReusableCellWithIdentifier:ID]; \
if (!cell) { \
cell=[[self alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID]; \
} \
return cell; \
} \
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier \
{ \
if (self==[super initWithStyle:style reuseIdentifier:reuseIdentifier]) { \
[self setUI]; \
} \
return self;\
}
//----------------------单例----------------------------
// .h文件
#define HJSingletonH + (instancetype)sharedInstance;

// .m文件
#define HJSingletonM \
static id _instace; \
\
+ (instancetype)allocWithZone:(struct _NSZone *)zone \
{ \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instace = [super allocWithZone:zone]; \
}); \
return _instace; \
} \
\
+ (instancetype)sharedInstance \
{ \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instace = [[self alloc] init]; \
}); \
return _instace; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return _instace; \
}
//----------------------单例----------------------------

//----------------------自定义cell-----------------------


//----------------------自定义cell-----------------------
//----------------------属性设置-------------------------
#define keyPath(objc,keyPath) @(((void)objc.keyPath, #keyPath))

#define APP_Frame_Height   [[UIScreen mainScreen] bounds].size.height

#define App_Frame_Width    [[UIScreen mainScreen] bounds].size.width

//比列
#define HJScaleWidth(__VA_ARGS__) (App_Frame_Width/375)*(__VA_ARGS__)
#define HJScaleHeight(__VA_ARGS__) (APP_Frame_Height/667)*(__VA_ARGS__)
#define HJScaleFont(__VA_ARGS__) (App_Frame_Width/375)*(__VA_ARGS__)

#define ALERT(msg)  [[[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:nil \
cancelButtonTitle:@"确定" otherButtonTitles:nil,nil] show]

#define App_Delegate ((AppDelegate*)[[UIApplication sharedApplication]delegate])

#define App_RootCtr  [self getCurrentViewController].navigationController.view

#define WEAKSELF __weak typeof(self) weakSelf = self


// ----------------font----------------
#define FONT_BIG        [UIFont fontWithName:@"PingFangSC-Light" size:16] /// 16
#define FONT_DEFATUL   [UIFont fontWithName:@"PingFangSC-Light" size:14] /// 14
#define FONT_SMALL     [UIFont fontWithName:@"PingFangSC-Light" size:12] /// 12
#define FONT_VERY_SMALL [UIFont fontWithName:@"PingFangSC-Light" size:10] /// 10
#define HJFont(FONTSIZE)  [UIFont systemFontOfSize:(FONTSIZE)]
#define ICBOLDFont(FONTSIZE)  [UIFont boldSystemFontOfSize:(FONTSIZE)]
//----------------------属性设置-------------------------
//十六进制颜色转换成UIColor
#define UIColorFromRGB(rgbValue)    [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define COLOR_(color)     [UIColor colorWithHexString:(color)]

#define COLOR_ORANGE                            UIColorFromRGB(0xf05b29)
#define COLOR_TEXT_DEFAULT                      UIColorFromRGB(0x333333)
#define COLOR_TEXT_GRAY                         UIColorFromRGB(0x666666)
#define COLOR_TEXT_LIGHT_GRAY                   UIColorFromRGB(0x999999)

#endif /* CommonMacro_h */
